package com.basic;

import com.frame.struts.BaseBean;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.ConvertUtils;

import com.frame.struts.ActionContext;
import com.utils.*;

import java.util.Date;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class MainSaleChangeForm
	extends BaseBean {
	public MainSaleChangeForm() {
	}
	
	  static{
	        ConvertUtils.register(new DateConverter(), Date.class);
	    }
	MainSaleChangeEntity msce = new MainSaleChangeEntity();
	private String oldId = "";
	public String addMainSaleChange() {
		HttpServletRequest request = ActionContext.getActionContext().
			getRequest();
		HttpServletResponse response = ActionContext.getActionContext().
			getResponse();
		BasicFactory factory = new BasicFactory();
		String qyid = (String) request.getSession().getAttribute("session_qyid");
		msce.setQyid(qyid);
		msce.setOptdate(new Date());
		msce.setOptrid(CommUtil.getUserId(request));
		msce.setXh(factory.getNextXh("qy_jyzybg", qyid));
		try {
			if (factory.addMainSaleChange(msce)) {
				response.sendRedirect("/basic/queryMangerMove.jsp");
			}
			else
			{
				response.sendRedirect("/basic/failed.jsp");
			}
		}
		catch (Exception e) {

		}

		return null;
	}

	public String modifyMainSaleChange() {
		System.out.println("oldId=" + this.getOldId());
		HttpServletRequest request = ActionContext.getActionContext().
			getRequest();
		HttpServletResponse response = ActionContext.getActionContext().
			getResponse();
		BasicFactory factory = new BasicFactory();
		String qyid = (String) request.getSession().getAttribute("session_qyid");
		msce.setQyid(qyid);
		msce.setOptdate(new Date());
		msce.setOptrid(CommUtil.getUserId(request));
		msce.setXh(factory.getNextXh("qy_jyzybg", qyid));
		factory.deleteMainSaleChange(qyid,
									 Integer.valueOf(this.getOldId()).intValue());
		try {
			if (factory.addMainSaleChange(msce)) {
				response.sendRedirect("basic/queryMangerMove.jsp");
			}
			else
			{
				response.sendRedirect("/basic/failed.jsp");
			}
		}
		catch (Exception e) {

		}
		return null;
	}

	public String getZjjyxm() {
		return msce.getZjjyxm();
	}

	public void setZjjyxm(String zjjyxm) {
		msce.setZjjyxm(zjjyxm);
	}

	public java.sql.Date getZjsj() {
		return msce.getZjsj();
	}

	public void setZjsj(java.sql.Date  zjsj) {
		msce.setZjsj(zjsj);
	}

	public String getOldId() {
		return this.oldId;
	}

	public void setOldId(String oldId) {
		this.oldId = oldId;
	}

	/**
	 * @return msce.getReturns the cszysj.
	 */
	public java.sql.Date getCszysj() {
		return msce.getCszysj();
	}

	/**
	 * @param cszysj The cszysj to set.
	 */
	public void setCszysj(java.sql.Date cszysj) {
		msce.setCszysj(cszysj);
	}

	/**
	 * @return msce.getReturns the jszysj.
	 */
	public java.sql.Date getJszysj() {
		return msce.getJszysj();
	}

	/**
	 * @param jszysj The jszysj to set.
	 */
	public void setJszysj(java.sql.Date jszysj) {
		msce.setJszysj(jszysj);
	}

	/**
	 * @return msce.getReturns the jyzynr.
	 */
	public String getJyzynr() {
		return msce.getJyzynr();
	}

	/**
	 * @param jyzynr The jyzynr to set.
	 */
	public void setJyzynr(String jyzynr) {
		msce.setJyzynr(jyzynr);
	}

	/**
	 * @return msce.getReturns the optdate.
	 */
	public Date getOptdate() {
		return msce.getOptdate();
	}

	/**
	 * @param optdate The optdate to set.
	 */
	public void setOptdate(Date optdate) {
		msce.setOptdate(optdate);
	}

	/**
	 * @return msce.getReturns the optrid.
	 */
	public String getOptrid() {
		return msce.getOptrid();
	}

	/**
	 * @param optrid The optrid to set.
	 */
	public void setOptrid(String optrid) {
		msce.setOptrid(optrid);
	}

	/**
	 * @return msce.getReturns the qyid.
	 */
	public String getQyid() {
		return msce.getQyid();
	}

	/**
	 * @param qyid The qyid to set.
	 */
	public void setQyid(String qyid) {
		msce.setQyid(qyid);
	}

	/**
	 * @return msce.getReturns the recstate.
	 */
	public String getRecstate() {
		return msce.getRecstate();
	}

	/**
	 * @param recstate The recstate to set.
	 */
	public void setRecstate(String recstate) {
		msce.setRecstate(recstate);
	}

	/**
	 * @return msce.getReturns the remark.
	 */
	public String getRemark() {
		return msce.getRemark();
	}

	/**
	 * @param remark The remark to set.
	 */
	public void setRemark(String remark) {
		msce.setRemark(remark);
	}

	/**
	 * @return msce.getReturns the xh.
	 */
	public int getXh() {
		return msce.getXh();
	}

	/**
	 * @param xh The xh to set.
	 */
	public void setXh(int xh) {
		msce.setXh(xh);
	}
	public java.sql.Date getJssj() {
		return msce.getJssj();
	}

	public void setJssj(java.sql.Date jssj) {
		msce.setJssj(jssj);
	}

	public String getJsjyxm() {
		return msce.getJsjyxm();
	}

	public void setJsjyxm(String jsjyxm) {
		msce.setJsjyxm(jsjyxm);
	}
}
